public class Instructor {  
    private String name;  
    // 假设一个教师可以教授多门课程  
    private List<Subject> subjects;  
  
    public Instructor(String name) {  
        this.name = name;  
        this.subjects = new ArrayList<>();  
    }  
  
    // 添加教授的课程  
    public void addSubject(Subject subject) {  
        this.subjects.add(subject);  
    }  
  
    // Getter和Setter方法  
    public String getName() {  
        return name;  
    }  
  
    public void setName(String name) {  
        this.name = name;  
    }  
  
    public List<Subject> getSubjects() {  
        return subjects;  
    }  
}  
  
// Subject.java  
public class Subject {  
    private String name;  
    private Instructor instructor; // 每门课程都有一个教师  
    // 假设每门课程有多个学生（这里为了简化，使用Set来避免重复学生）  
    private Set<Student> students;  
  
    public Subject(String name, Instructor instructor) {  
        this.name = name;  
        this.instructor = instructor;  
        this.students = new HashSet<>();  
    }  
  
    // 添加学生到课程中  
    public void addStudent(Student student) {  
        this.students.add(student);  
    }  
  
    // Getter和Setter方法  
    public String getName() {  
        return name;  
    }  
  
    public void setName(String name) {  
        this.name = name;  
    }  
  
    public Instructor getInstructor() {  
        return instructor;  
    }  
  

    public Set<Student> getStudents() {  
        return students;  
    }  
}  
  
// School.java  
public class School {  
    private String name;  
    // 假设学校有多个学生（这里为了简化，使用Set来避免重复学生）  
    private Set<Student> students;  
  
    public School(String name) {  
        this.name = name;  
        this.students = new HashSet<>();  
    }  
  
    // 添加学生到学校  
    public void addStudent(Student student) {  
        this.students.add(student);  
    }  
  
    // Getter和Setter方法  
    public String getName() {  
        return name;  
    }  
  
    public void setName(String name) {  
        this.name = name;  
    }  
  
    public Set<Student> getStudents() {  
        return students;  
    }  
}  
  
// Student.java  
public class Student {  
    private String name;  
    private School school;  
    // 假设学生可以选择多门课程  
    private List<Subject> subjects;  
  
    public Student(String name, School school) {  
        this.name = name;  
        this.school = school;  
        this.subjects = new ArrayList<>();  
    }  
  
    // 添加选择的课程  
    public void selectSubject(Subject subject) {  
        this.subjects.add(subject);  
        // 同时，将学生添加到课程中（这是双向关系）  
        subject.addStudent(this);  
    }  
  
    // Getter和Setter方法  
    public String getName() {  
        return name;  
    }  
  
    public void setName(String name) {  
        this.name = name;  
    }  
  
    public School getSchool() {  
        return school;  
    }  
  
  
    public List<Subject> getSubjects() {  
        return subjects;  
    }  
}